import axios from 'axios'

interface IRequestConfig {
  url: string
  method?: 'get' | 'post' | 'put' | 'delete'
  data?: any
  headers?: any
}

export async function http(data: IRequestConfig) {
  console.info('request --> ', data)

  try {
    const res = await axios.request({
      ...data,
      headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }
    })
    console.log(res)
  } catch (error) {
    console.error(error)
  }
}
